package com.heu.blood.recycle.controller;

import java.util.Arrays;
import java.util.Map;

import com.heu.blood.common.aop.ControllerLogAnnotation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.heu.blood.recycle.entity.BloodBagRecycleEntity;
import com.heu.blood.recycle.service.BloodBagRecycleService;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;



/**
 * 
 *
 * @author lyj
 * @email lyj@heu.com
 * @date 2023-06-15 15:44:00
 */
@RestController
@RequestMapping("recycle/bloodbagrecycle")
public class BloodBagRecycleController {
    @Autowired
    private BloodBagRecycleService bloodBagRecycleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ControllerLogAnnotation(module = "血袋回收", operate = "分页条件查询血袋回收信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = bloodBagRecycleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ControllerLogAnnotation(module = "血袋回收", operate = "根据id查询血袋回收信息")
    public R info(@PathVariable("id") Long id){
		BloodBagRecycleEntity bloodBagRecycle = bloodBagRecycleService.getById(id);

        return R.ok().put("bloodBagRecycle", bloodBagRecycle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ControllerLogAnnotation(module = "血袋回收", operate = "保存一条血袋回收信息")
    public R save(@RequestBody BloodBagRecycleEntity bloodBagRecycle){



        return bloodBagRecycleService.save(bloodBagRecycle) ? R.ok("保存成功") : R.ok("保存失败");
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ControllerLogAnnotation(module = "血袋回收", operate = "更新血袋回收信息")
    public R update(@RequestBody BloodBagRecycleEntity bloodBagRecycle){
		bloodBagRecycleService.updateById(bloodBagRecycle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ControllerLogAnnotation(module = "血袋回收", operate = "血袋回收批量删除")
    public R delete(@RequestBody Long[] ids){
		bloodBagRecycleService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
